<?php
get_header();
while (have_posts()) : the_post();
    ?>
    <div class="row">
        <div class="col-md-6">
            <div><?php echo getItemPostNews(); ?></div>
            <div class="fb-comments" data-href="<?php echo get_permalink(); ?>" data-numposts="20" data-colorscheme="light"></div>
        </div>
        <div class="col-md-6 content-ex">
            <?php
            if (is_user_logged_in()) {
                $cont = get_the_content();
                if (!empty($cont)) {
                    the_content();
                } else {
                    $domain = getURLExtend(get_the_ID());
                    $regularEx = getRegularEx($domain);
                    if ($regularEx) {
                        $targetlink = get_post_meta(get_the_ID(), 'post_link_target', TRUE);
                        $contents = @file_get_contents(trim($targetlink));
                        if ($contents) {
                            include get_template_directory() . '/html_dom.php';
                            $html = str_get_html($contents);
                            $temp = $html->find($regularEx, 0)->innertext;
                            if (!empty($temp)) {
                                echo $temp;
                                wp_update_post(array('ID' => get_the_ID(), 'post_content' => $temp));
                            }
                        }
                    }
                }
            }
            ?>
        </div>

    </div>
    <script type="text/javascript">
        jQuery(document).ready(function() {
            /*run when load*/
            convertTimetoString();
            getTotalCountFB();
            setInterval(function() {
                convertTimetoString();
                getTotalCountFB();
            }, 60000);

        })

    </script>
    <?php
endwhile;
get_footer();
?>
